package com.fsquare.inventory.service;

import java.util.List;
import java.util.Map;

import org.broadleafcommerce.core.catalog.domain.Sku;

import com.fsquare.inventory.domain.SkuInventory;
import com.fsquare.inventory.domain.SkuMovement;
import com.fsquare.inventory.domain.SkuMovement.MovementType;

public interface InventoryService {
	
	public List<SkuMovement> getSkuMovements(Sku sku);
	
	public List<SkuMovement> getSkuMovements(Long skuId);

	public SkuMovement saveMovement(SkuMovement skuMovement);
	
	public SkuInventory getInventory(Sku sku);
	
	public SkuInventory getInventory(Long skuId);
	
	public SkuInventory saveInventory(SkuInventory skuInventory);
	
	public boolean isAvailable(Long skuId, Integer quantity);
	
	boolean isAvailable(SkuInventory inventory, Integer quantity);
	
	public Integer retrieveQuantityAvailable(Long skuId);
	
	/**
     * Attempts to decrement inventory if it is available.
     * 
     * @param skuId
     * @param quantity
     * @throws BasicInventoryUnavailableException
     */
    public SkuInventory decrementInventory(Long skuId, int quantity) throws InventoryUnavailableException;

    /**
     * Attempts to decrement inventory for a map of Sku ids and quantities.
     * 
     * Quantities must be greater than zero or an IllegalArgumentException will be thrown.
     * 
     * @param skuQuantities
     * @throws BasicInventoryUnavailableException
     */
    public void decrementInventory(Map<Long, Integer> skuQuantities) throws InventoryUnavailableException;

    /**
     * Attempts to increment inventory.
     * 
     * Quantity must be greater than zero or an IllegalArgumentException will be thrown.
     * 
     * @param skuId
     * @param quantity
     * @return 
     * @throws InventoryUnavailableException 
     */
    public SkuInventory incrementInventory(Long skuId, int quantity) throws InventoryUnavailableException;

    /**
     * Attempts to increment inventory for a map of Sku ids and quantities.
     * 
     * Quantities must not be null and must be greater than zero or an IllegalArgumentException will be thrown.
     * 
     * @param skuQuantities
     */
    public void incrementInventory(Map<Long, Integer> skuQuantities);


    public SkuInventory updateInventory(SkuInventory inventory, Integer updateQuantity, MovementType movementType) throws InventoryUnavailableException;

    public SkuInventory createNewSkuInventory(Long skuId) throws InventoryUnavailableException;

    public SkuInventory createNewSkuInventory(Long skuId, Integer quatity) throws InventoryUnavailableException;



	
}
